package com.xq.config;

import com.xq.exception.BusinessException;
import com.xq.vo.JsonVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理自定义的数据库异常
     */
    @ExceptionHandler(BusinessException.class)
    JsonVO<?> handleBusinessException(BusinessException e) {
        log.error(e.getMessage(), e);
        return JsonVO.fail(e.getMessage());
    }

}
